<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title></title>
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
	<link rel="stylesheet" type="text/css" href="../../css/font-awesome.css" />
</head>

<body>
	<div class="aui-card-list" id="list">
		<script id="listTemplate" type="text/x-dot-template">
			<input type="hidden" id="olderId" value="{{=it.geroOcpyOrderAmple.olderId}}" />
			<input type="hidden" id="orderId" value="{{=it.geroOcpyOrderAmple.id}}" />
			<input type="hidden" id="olderIdCardNumber" value="{{=it.geroOcpyOrderAmple.olderIdCardNumber}}" />
			<input type="hidden" id="sdmOosEligibleFlag" value="{{=it.geroOcpyOrderAmple.sdmOosEligibleFlag}}" />
			<div class="aui-card-list-content">
				<ul class="aui-list aui-form-list">
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								老人姓名：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.olderName}}
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								证件号码：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.olderIdCardNumber}}
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								楼座名称：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.buildingName}}
							</div>
						</div>
					</li>

					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								楼层号：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.floorName}}
							</div>
						</div>
					</li>

					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								房间号：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.roomCode}}
							</div>
						</div>
					</li>

					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								床位号：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.bedCode}}
							</div>
						</div>
					</li>
					<li class="aui-list-item">
						<div class="aui-list-item-inner">
							<div class="aui-list-item-label">
								护理等级：
							</div>
							<div class="aui-list-item-input">
								{{=it.geroOcpyOrderAmple.currentNursingLevelName}}
							</div>
						</div>
					</li>

				</ul>
			</div>
		</script>
	</div>
	<footer class="aui-bar aui-bar-tab aui-border-t" id="footer">
		<div class="aui-bar-tab-item aui-border-r" tapmode id="upload">
			<i class="fa fa-upload"></i>
			<div class="aui-bar-tab-label">
				附件上传
			</div>
		</div>
		<div class="aui-bar-tab-item" tapmode id="upload_list">
			<i class="fa fa-list"></i>
			<div class="aui-bar-tab-label">
				附件列表
			</div>
		</div>
	</footer>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/doT.js"></script>
<script type="text/javascript" src="../../script/util.js"></script>
<script type="text/javascript">
	apiready = function() {
		// 老人编号
		var pid = api.pageParam.id;
		api.parseTapmode();
		api.ajax({
			url: base + 'gero/api/nurseTerminal/idCardInfoCollect/getOrderAmpleByOrderId',
			method: 'post',
			data: {
				values: {
					ocpyOrderId: api.pageParam.id,
					token: $api.getStorage('userinfo').token
				}
			}
		}, function(ret, err) {
			console.log(JSON.stringify(ret));
			//coding...
			if (ret) {
				console.log(JSON.stringify(ret));
				ret.base = base;
				var template = $api.byId('listTemplate');
				var list_content = $api.byId('list');
				var pagefn = doT.template(template.text);
				$api.html(list_content, pagefn(ret));
			} else {
				doLogin();
			}
		});
		// 附件上传
		$api.addEvt($api.byId('upload'), 'click', function() {
			if ($api.val($api.byId('olderIdCardNumber')).indexOf('21')==0) {
				upload_file("0");
			} else {
				api.actionSheet({
					title: '附件上传',
					cancelTitle: '取消',
					buttons: ['普通附件', '户籍资料']
				}, function(ret, err) {
					if (ret) {
						switch (ret.buttonIndex) {
							case 1:
								upload_file("0");
								break;
							case 2:
								savePics();
								break;
						}
					} else {
						alert(JSON.stringify(err));
					}
				});
			}
		});
		// 附件列表
		$api.addEvt($api.byId('upload_list'), 'click', function() {
			var id = $api.val($api.byId('olderId'));
			console.log("老人id:"+id);
			//openBrowse(api.wgtRootDir + '/html/person/file.html', '附件列表', false, 'file_list', id);
			//openWin('file',api.wgtRootDir + '/html/person/file_index.html',{id:id});
			api.openWin({
			    name: 'file_index',
			    url: api.wgtRootDir + '/html/person/file_index.html',
			    pageParam: {
			        id: id
			    }
			});

		});

	};
	// 上传户口
	function savePics() {
		api.getPicture({
			sourceType: 'camera',
			encodingType: 'jpg',
			mediaValue: 'pic',
			destinationType: 'base64',
			quality: 100,
			targetWidth: 480,
			targetHeight: 800,
			saveToPhotoAlbum: false
		}, function(ret, err) {
			if (ret && ret.base64Data != "") {
				api.showProgress({

				});

				api.ajax({
					url: base + 'gero/api/sdm/oos/savePics',
					method: 'post',
					data: {
						values: {
							token: $api.getStorage('userinfo').token,
							//olderId: $api.val($api.byId('olderId')),
							orderId: $api.val($api.byId('orderId')),
							base64Image: ret.base64Data.substring(ret.base64Data.indexOf(",") + 1)
						}
					}
				}, function(ret, err) {
					console.log("返回数据：" + JSON.stringify(ret));
					if (ret && ret.code === "200") {
						api.alert({
							title: '上传成功'
						}, function(ret, err) {
							//coding...
						});
					} else {
						api.alert({
							title: '上传失败'
						}, function(ret, err) {

						});

					}
					api.hideProgress();
				});



			} else {
				api.alert({
					title: '请拍照后上传'
				}, function(ret, err) {

				});


			}
		});

	}
	// 上传文件【普通】
	function upload_file(picFlag) {
		api.getPicture({
			sourceType: 'camera',
			encodingType: 'jpg',
			mediaValue: 'pic',
			destinationType: 'base64',
			targetWidth: 480,
			targetHeight: 800,
			quality: 100
		}, function(ret, err) {
			if (ret && ret.base64Data != "") {
				api.showProgress({});

				api.ajax({
					url: base + 'gero/open/fileUpload/api/savePics',
					method: 'post',
					data: {
						values: {
							olderId: $api.val($api.byId('olderId')),
							base64Image: ret.base64Data.substring(ret.base64Data.indexOf(",") + 1),
							picFlag: picFlag
						}
					}
				}, function(ret, err) {
					//coding...
					console.log("返回数据：" + JSON.stringify(ret));
					if (ret && ret.code === "200") {
						api.alert({
							title: '上传成功'
						}, function(ret, err) {
							//coding...
						});
					} else {
						api.alert({
							title: '上传失败'
						}, function(ret, err) {

						});

					}
					api.hideProgress();

				});
			} else {
				api.alert({
					title: '请拍照后上传'
				}, function(ret, err) {

				});
			}
		});

	}
</script>

</html>
